import { APIResponseBody, GlobalConfig, SourceData } from '@ugeez/frontend-commons/lib/types';
/** 如果接口返回数据结构不是 
 { code, data, message, extMessage }

 则需要实现如下的方法，修改底层的处理逻辑

const convertResponse = (res: SourceData): APIResponseBody => {
    const body: APIResponseBody = {
        code: res['code'],
        data: res['data'],
        message: res['extMessage'] || res['message'],
    };
    return body;
};

const checkNoPermission = (body: APIResponseBody): boolean => {
    if (body.code === 'err02' || body.code === 'err03') {
        return true;
    }
    return false;
}

const checkSuccess = (body: APIResponseBody): boolean => {
    if (Number(body.code) === 1) {
        return true;
    }
    return false;
}

export default (globalConfig: GlobalConfig): GlobalConfig => {
    globalConfig.service = {
        convertResponse,
        checkNoPermission,
        checkSuccess,
    };
    return globalConfig;
}
 */

//不需要特殊处理
export default (globalConfig: GlobalConfig): GlobalConfig => {
    return globalConfig;
}